const setData = (
  key,
  ContentArr,
  urlPic,
  // deleteData,
  // deleteUrl,
  location,
  Similarity,
  Content,
  noContent
) => {
  const textArr = [];
  const TextPic = [];
  const PicArr = [];
  let i = 1;
  if (key.operate === "add") {
    ContentArr.forEach(item => {
      if (item.key.substring(0, 2) === "in" && item.value !== "回车") {
        const tmp = {};
        tmp.messageType = 0;
        tmp.messageContent = item.value;
        tmp.messageOrder = i;
        tmp.messageUnitName = "";
        tmp.parameterNullContent = noContent;
        i += 1;
        textArr.push(tmp);
        TextPic.push(tmp);
      }
      if (item.key.substring(0, 2) === "se") {
        const tmp = {};
        tmp.messageType = 1;
        tmp.messageParameter = item.value;
        tmp.messageOrder = i;
        tmp.messageUnitName = "";
        tmp.parameterNullContent = noContent;
        i += 1;
        textArr.push(tmp);
        TextPic.push(tmp);
      }
      if (item.key.substring(0, 2) === "in" && item.value === "回车") {
        const tmp = {};
        tmp.messageType = 0;
        tmp.messageContent = "\n";
        tmp.messageOrder = i;
        tmp.messageUnitName = "";
        tmp.parameterNullContent = noContent;
        i += 1;
        textArr.push(tmp);
        TextPic.push(tmp);
      }
    });
    if (Content === "4") {
      const dataName = ["partSnapshot", "fullSnapshot", "idPhoto"];
      urlPic.forEach((item, index) => {
        const tmp = {};
        tmp.messageType = 2;
        tmp.messageParameter = item.value;
        tmp.messageOrder = i;
        tmp.messageUnitName = dataName[index];
        tmp.parameterNullContent = noContent;
        i += 1;
        PicArr.push(tmp);
        TextPic.push(tmp);
      });
    }
    if (Content !== "4") {
      urlPic.forEach(item => {
        const tmp = {};
        tmp.messageType = 2;
        tmp.messageParameter = item.value;
        tmp.messageOrder = i;
        tmp.messageUnitName = "";
        tmp.parameterNullContent = noContent;
        i += 1;
        PicArr.push(tmp);
        TextPic.push(tmp);
      });
    }
    if (Content === "4") {
      const tmp = location;
      tmp.messageOrder = i;
      tmp.parameterNullContent = noContent;
      TextPic.push(tmp);
      i += 1;
      const temp = Similarity;
      temp.messageOrder = i;
      temp.parameterNullContent = noContent;
      TextPic.push(temp);
      i += 1;
    }
    return { textArr, TextPic, PicArr };
  }
  ContentArr.forEach(item => {
    if (item.key.substring(0, 2) === "in" && item.value !== "回车") {
      const tmp = {};
      tmp.messageType = 0;
      tmp.messageContent = item.value;
      tmp.messageOrder = i;
      tmp.messageUnitName = "";
      tmp.parameterNullContent = noContent;
      i += 1;
      textArr.push(tmp);
      TextPic.push(tmp);
    }
    if (item.key.substring(0, 2) === "se") {
      const tmp = {};
      tmp.messageType = 1;
      tmp.messageParameter = item.value;
      tmp.messageOrder = i;
      tmp.messageUnitName = "";
      tmp.parameterNullContent = noContent;
      i += 1;
      textArr.push(tmp);
      TextPic.push(tmp);
    }
    if (item.key.substring(0, 2) === "in" && item.value === "回车") {
      const tmp = {};
      tmp.messageType = 0;
      tmp.messageContent = "\n";
      tmp.messageOrder = i;
      tmp.messageUnitName = "";
      tmp.parameterNullContent = noContent;
      i += 1;
      textArr.push(tmp);
      TextPic.push(tmp);
    }
  });
  urlPic.forEach(item => {
    const tmp = {};
    tmp.messageType = 2;
    tmp.messageParameter = item.value;
    tmp.messageOrder = i;
    tmp.messageUnitName = item.messageUnitName ? item.messageUnitName : "";
    tmp.parameterNullContent = noContent;
    i += 1;
    PicArr.push(tmp);
    TextPic.push(tmp);
  });
  if (Content === "4") {
    const tmp = location;
    tmp.messageOrder = i;
    tmp.parameterNullContent = noContent;
    TextPic.push(tmp);
    i += 1;
    const temp = Similarity;
    temp.messageOrder = i;
    temp.parameterNullContent = noContent;
    TextPic.push(temp);
    i += 1;
  }
  return { textArr, TextPic, PicArr };
};
export default { setData };
